home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Experimental BBS Explossion 3
/
Experimental BBS Explossion III.iso
/
c
/
bc_pas_1.zip
/
MEMORY.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-10-19
|
2KB
|
125 lines
page 64,131
Title MEM.ASM -- Memory Allocation Routines
; /*\
;---|*|------------====< MEM.ASM >====------------
;---|*|
;---|*| Copyright (c) 1991, 1992 Media Vision, Inc. All rights reserved.
;---|*|
; \*/
.xlist
include model.inc
include masm.inc
include common.inc
.list
;
;---------------------------========================---------------------------
;---------------------------====< DATA SECTION >====---------------------------
;---------------------------========================---------------------------
;
if MODELSIZE eq 0
.code
else
.data
endif
;
;---------------------------========================---------------------------
;---------------------------====< CODE SECTION >====---------------------------
;---------------------------========================---------------------------
;
.code
; /*\
;---|*|------------====< _memmalloc ( long ) >====------------
;---|*|
;---|*| Allocate a block of memory from DOS
;---|*|
;---|*| Entry Conditions:
;---|*| dParm1 - is the size in bytes
;---|*|
;---|*| Exit Conditions:
;---|*| dword is the block pointer, else 0 if in error
;---|*|
; \*/
public _memmalloc
_memmalloc proc
push bp
mov bp,sp
;
; get the # of paragraphs into BX
;
mov bx,dParm1+0
mov dx,dParm1+2
mov cl,4
shr bx,cl
mov cl,12
shl dx,cl
add bx,dx ; bx = hi order 16 bits out of 24 bits
inc bx ; get one more 16 byte block
;
; call DOS for a memory block
;
mov ah,48h
int 21h
;
; carry is set if in error.
;
cmc ; set carry if no error
sbb bx,bx
and ax,bx ; ax = 0 if in error, else a segment
sub dx,dx
xchg ax,dx ; dx:ax holds the pointer
pop bp
ret
_memmalloc endp
; /*\
;---|*|------------====< _memfree ( void far * ) >====------------
;---|*|
;---|*| Releases the allocated block of memory from DOS
;---|*|
;---|*| Entry Conditions:
;---|*| dParm1 - is the pointer to the block
;---|*|
;---|*| Exit Conditions:
;---|*| None
;---|*|
; \*/
public _memfree
_memfree proc
push bp
mov bp,sp
push es
;
; get the # of paragraphs into BX
;
mov es,dParm1+2
;
; just do it...
;
mov ah,49h
int 21h
pop es
pop bp
ret
_memfree endp
; /*\
;---|*| end of MEM.ASM
; \*/
end